home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / qb2 / pro20 / disktype.bas < prev    next >
Encoding:
BASIC Source File  |  1988-04-14  |  2.2 KB  |  82 lines

  1. TYPE RegType
  2.      ax    AS INTEGER
  3.      bx    AS INTEGER
  4.      cx    AS INTEGER
  5.      dx    AS INTEGER
  6.      bp    AS INTEGER
  7.      si    AS INTEGER
  8.      di    AS INTEGER
  9.      flags AS INTEGER
  10.      ds    AS INTEGER
  11.      es    AS INTEGER
  12. END TYPE
  13.  
  14. DECLARE FUNCTION GetDrive$ ()
  15. DECLARE SUB InterruptX (intnum AS INTEGER, inreg AS RegType, outreg AS RegType)
  16.  
  17. DIM regs AS RegType
  18.  
  19. IF COMMAND$ <> "" THEN
  20.    Drive$ = LEFT$(COMMAND$, 1)
  21. ELSE
  22.    Drive$ = GetDrive$
  23. END IF
  24.  
  25. 'get the free disk space
  26.  
  27. regs.ax = &H3600                    'function 36H: get disk allocation info.
  28. regs.dx = ASC(Drive$) - 64          'Drive #: 0=default, 1=A:, 2=B:, etc
  29. CALL Interrupt(&H21, regs, regs)    'call int 21H
  30. BytesAvail& = regs.ax * regs.cx     'AX=Sectors/Custer, CX=Bytes/Sector
  31. BytesAvail& = regs.bx * BytesAvail& 'BX=Number of available clusters
  32.                                     'DX returns the Cluters/Drive, but is
  33.                                     'is not used in this routine.
  34.  
  35. BytesTotal& = regs.cx * regs.ax
  36. BytesTotal& = BytesTotal& * regs.dx
  37.  
  38. 'get disk ID byte
  39.  
  40. regs.ax = &H1C00
  41. regs.dx = ASC(Drive$) - 64
  42. CALL InterruptX(&H21, regs, regs)
  43.  
  44. DEF SEG = regs.ds
  45. IDB = PEEK(regs.bx)
  46. DEF SEG
  47.  
  48. SELECT CASE IDB
  49.    CASE &HF0
  50.       PRINT "3.5 inch floppy, 1.44 meg,  double sided, 18 sectors/track."
  51.    CASE &HF8
  52.       PRINT "Fixed disk."
  53.    CASE &HF9
  54.       IF BytesTotal& > 800000 THEN
  55.          PRINT "5.25 inch floppy, 1.2 meg, double sided, 15 sectors/track."
  56.       ELSE
  57.          PRINT "3.5 inch floppy, 720K,  double sided, 9  sectors/track."
  58.       END IF
  59.    CASE &HFC
  60.       PRINT "5.25 inch floppy, 180K, single sided, 9 sectors/track."
  61.    CASE &HFD
  62.       PRINT "5.25 inch floppy, 360K, double sided, 9 sectors/track."
  63.    CASE &HFE
  64.       PRINT "5.25 inch floppy, 160K, single sided, 8 sectors/track."
  65.    CASE &HFF
  66.       PRINT "5.25 inch floppy, 320K, double sided, 8 sectors/track."
  67.    CASE ELSE
  68. END SELECT
  69.  
  70. PRINT USING "###,###,###"; BytesTotal&; : PRINT " bytes total disk space,"
  71. PRINT USING "###,###,###"; BytesAvail&; : PRINT " bytes available."
  72.  
  73. FUNCTION GetDrive$
  74.   
  75.    DIM regs AS RegType
  76.    regs.ax = &H1900
  77.    CALL Interrupt(&H21, regs, regs)
  78.    GetDrive$ = CHR$(65 + regs.ax MOD 256)
  79.  
  80. END FUNCTION
  81.  
  82.